public class J05Sort {
    public static void main(String[] args) {
        //小 -> 大
        //选择排序
        int[] arr = {1,100,20,60,45,23,77};
        /*


        {5,1,100,20,60,45,23,77}




        {1,100,20,60,45,23,77}
        {1,20,100,60,45,23,77}
        {1,20,23,100,60,45,77}
         */
        //从下标0开始，依次与后面的每一个比较
        for (int i = 0; i <= arr.length-2; i++) {
            for (int j = i+1; j <= arr.length-1; j++) {
                if(arr[j]<arr[i]){
                    //发现后面有更小的，交换位置
                    int temp = arr[j];
                    arr[j] = arr[i];
                    arr[i] = temp;
                }
            }
        }
        //打印数组
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }
}
/*

int a = 5;
int b = 3;

int c = a;
a = b;
b = c;




 */
class AA{
    public static void main(String[] args) {
        int a;
//        System.out.println(a);
    }
}